﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using STX.Domain;
namespace STX.Web.Framework.Security
{
    public static class Auth
    {
        public static bool CheckRights(this PositionEnum value, RightsEnum right)
        {
            var filedInfo = value.GetType().GetField(value.ToString());
            if (filedInfo == null) return false;
            var cas = (AuthAttribute[])filedInfo.GetCustomAttributes(typeof(AuthAttribute), false);
            if (cas.Length > 0)
            {
                return (cas[0].Rights & right) > 0;
            }
            return false;
        }
    }
}
